package com.swh.zuul;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.netflix.zuul.context.ContextLifecycleFilter;
import com.netflix.zuul.http.ZuulServlet;
import com.swh.zuul.filters.pre.SimplerFilter;

/**
 * 路由网关启动入口，所有面向服务的请求都应当先过Gateway
 * 
 * @author sangwenhao-桑文豪
 * @date 2016年12月30日 下午11:19:55
 */
@SpringBootApplication
@EnableZuulProxy
// zuul网关代理服务
 @RestController
@EnableDiscoveryClient
public class UserCloudZuulApplication {

	 @RequestMapping("/")
	 public String isStartSuccess(){
	 return "UserCloudZuulApplication is start success!";
	 }

	@Bean
	public SimplerFilter simplerFilter() {
		return new SimplerFilter();
	}

	public static void main(String[] args) {
		SpringApplication.run(UserCloudZuulApplication.class, args);
	}
/*
	@Bean
	public ServletRegistrationBean zuulServlet() {
		ServletRegistrationBean servlet = new ServletRegistrationBean(
				new ZuulServlet());
		servlet.addUrlMappings("/test");
		return servlet;
	}

	@Bean
	public FilterRegistrationBean contextLifecycleFilter() {
		FilterRegistrationBean filter = new FilterRegistrationBean(
				new ContextLifecycleFilter());
		filter.addUrlPatterns("/*");
		return filter;
	}*/
}
